import http from "@/config/request";

/** 发表评论 */
export const addComment = (data) => {
    return new Promise((resolve, reject) => {
        http.post("/cms/app-site-comment/create", data).then((res) => {
            resolve(res);
        });
    });
};

/** 回复评论 */
export const applyComment = (data) => {
    return new Promise((resolve, reject) => {
        http.post("/comment/apply", data).then((res) => {
            resolve(res);
        });
    });
};

/** 点赞评论 */
export const thumbUpComment = (id) => {
    return new Promise((resolve, reject) => {
        http.put("/comment/thumbUp/" + id, {}).then((res) => {
            resolve(res);
        });
    });
};

/** 取消点赞评论 */
export const cancelThumbUp = (id) => {
    return new Promise((resolve, reject) => {
        http.put("/comment/cancelThumbUp/" + id, {}).then((res) => {
            resolve(res);
        });
    });
};

/** 删除自己的评论 */
export const deleteComment = (id, parent_id = 0) => {
    return new Promise((resolve, reject) => {
        http.delete(`/cms/app-site-comment/delete?id=${id}`, {}).then((res) => {
            resolve(res);
        });
    });
};

/** 获取评论 */
export const frontGetCommentPage = (params) => {
    return new Promise((resolve, reject) => {
        http.get("/cms/app-site-comment/page", {params}).then((res) => {
            resolve(res);
        });
    });
};

// 获取评论总条数
export const frontGetCommentTotal = (params) => {
    return new Promise((resolve, reject) => {
        http.get("/cms/app-site-comment/getCommentTotal", {params}).then((res) => {
            resolve(res);
        });
    });
};
